package com.mayikt.controller;

import com.mayikt.resp.CommonResp;
import com.mayikt.resp.StatisticResp;
import com.mayikt.service.EbookSnapshotService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("/ebook-snapshot")
@RestController
public class EbookSnapshotController {
    @Resource
    private EbookSnapshotService ebookSnapshotService;

    /**
     * 获取昨天和今天的统计数据
     * @return
     */
    @GetMapping("/get-statistic")
    public CommonResp<List<StatisticResp>> getStatistic() {
        CommonResp<List<StatisticResp>> commonResp = new CommonResp<>();
        List<StatisticResp> statistic = ebookSnapshotService.getStatistic();
        commonResp.setData(statistic);
        return commonResp;
    }

    /**
     * 获取近30天的统计数据
     * @return
     */
    @GetMapping("/get-month-statistic")
    public CommonResp<List<StatisticResp>> getMonthStatistic() {
        CommonResp<List<StatisticResp>> commonResp = new CommonResp<>();
        List<StatisticResp> statistic = ebookSnapshotService.getMonthStatistic();
        commonResp.setData(statistic);
        return commonResp;
    }
}
